/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bash.carrep.dao.enties;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author bash
 */
@Entity
@Table(name = "declaration", catalog = "carrepdb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Declaration.findAll", query = "SELECT d FROM Declaration d"),
    @NamedQuery(name = "Declaration.findByIdDeclaration", query = "SELECT d FROM Declaration d WHERE d.idDeclaration = :idDeclaration"),
    @NamedQuery(name = "Declaration.findByDateDeclaration", query = "SELECT d FROM Declaration d WHERE d.dateDeclaration = :dateDeclaration")})
public class Declaration implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idDeclaration", nullable = false)
    private Integer idDeclaration;
    @Basic(optional = false)
    @NotNull
    @Column(name = "dateDeclaration", nullable = false)
    @Temporal(TemporalType.DATE)
    private Date dateDeclaration;
    @JoinColumn(name = "idTypeDeclaration", referencedColumnName = "idtypeDeclaration", nullable = false)
    @ManyToOne(optional = false)
    private Typedeclaration idTypeDeclaration;
    @JoinColumn(name = "idlogin", referencedColumnName = "username", nullable = false)
    @ManyToOne(optional = false)
    private Login idlogin;
    @JoinColumn(name = "nif", referencedColumnName = "NIF", nullable = false)
    @ManyToOne(optional = false)
    private Personne nif;
    @JoinColumn(name = "idAutomobile", referencedColumnName = "idAutomobile", nullable = false)
    @ManyToOne(optional = false)
    private Automobile idAutomobile;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "declaration")
    private List<OperationEffectue> operationEffectueList;

    public Declaration() {
    }

    public Declaration(Integer idDeclaration) {
        this.idDeclaration = idDeclaration;
    }

    public Declaration(Integer idDeclaration, Date dateDeclaration) {
        this.idDeclaration = idDeclaration;
        this.dateDeclaration = dateDeclaration;
    }

    public Integer getIdDeclaration() {
        return idDeclaration;
    }

    public void setIdDeclaration(Integer idDeclaration) {
        this.idDeclaration = idDeclaration;
    }

    public Date getDateDeclaration() {
        return dateDeclaration;
    }

    public void setDateDeclaration(Date dateDeclaration) {
        this.dateDeclaration = dateDeclaration;
    }

    public Typedeclaration getIdTypeDeclaration() {
        return idTypeDeclaration;
    }

    public void setIdTypeDeclaration(Typedeclaration idTypeDeclaration) {
        this.idTypeDeclaration = idTypeDeclaration;
    }

    public Login getIdlogin() {
        return idlogin;
    }

    public void setIdlogin(Login idlogin) {
        this.idlogin = idlogin;
    }

    public Personne getNif() {
        return nif;
    }

    public void setNif(Personne nif) {
        this.nif = nif;
    }

    public Automobile getIdAutomobile() {
        return idAutomobile;
    }

    public void setIdAutomobile(Automobile idAutomobile) {
        this.idAutomobile = idAutomobile;
    }

    @XmlTransient
    public List<OperationEffectue> getOperationEffectueList() {
        return operationEffectueList;
    }

    public void setOperationEffectueList(List<OperationEffectue> operationEffectueList) {
        this.operationEffectueList = operationEffectueList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idDeclaration != null ? idDeclaration.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Declaration)) {
            return false;
        }
        Declaration other = (Declaration) object;
        if ((this.idDeclaration == null && other.idDeclaration != null) || (this.idDeclaration != null && !this.idDeclaration.equals(other.idDeclaration))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.bash.carrep.dao.enties.Declaration[ idDeclaration=" + idDeclaration + " ]";
    }
    
}
